/*
 * @Author: Await
 * @Date: 2025-05-09 11:15:00
 * @LastEditors: Await
 * @LastEditTime: 2025-05-09 11:15:00
 * @Description: 图表相关类型定义
 */

import * as echarts from 'echarts';
import React from 'react';

/**
 * 图表基础组件属性接口
 */
export interface ChartBaseProps {
  option?: any;
  data?: any[];
  dataConfig?: any;
  theme?: string | object;
  renderer?: 'canvas' | 'svg';
  animation?: boolean;
  loading?: boolean;
  width?: string | number;
  height?: string | number;
  style?: React.CSSProperties;
  className?: string;
  onChartReady?: (chart: echarts.ECharts) => void;
  onEvents?: Record<string, Function>;
}

/**
 * 图表基础组件引用接口
 */
export interface ChartBaseRef {
  getEChartsInstance: () => echarts.ECharts | null;
  resize: () => void;
  clear: () => void;
  setOption: (option: any) => void;
}

/**
 * 图表配置Hook参数接口
 */
export interface UseChartConfigParams {
  option?: any;
  data?: any[];
  dataConfig?: any;
  animation?: boolean;
  theme?: string | object;
}

/**
 * 图表钩子参数接口
 */
export interface UseChartParams {
  chartRef: React.RefObject<HTMLDivElement>;
  theme?: string | object;
  renderer?: 'canvas' | 'svg';
  onChartReady?: (chart: echarts.ECharts) => void;
  onEvents?: Record<string, Function>;
}

/**
 * 图表渲染组件属性接口
 */
export interface ChartRendererProps {
  option?: any;
  theme?: string | object;
  renderer?: 'canvas' | 'svg';
  width?: string | number;
  height?: string | number;
  loading?: boolean;
  onChartReady?: (chart: echarts.ECharts) => void;
  onEvents?: Record<string, Function>;
  className?: string;
  style?: React.CSSProperties;
  onError?: (error: string) => void;
}

/**
 * 图表加载组件属性接口
 */
export interface ChartLoadingProps {
  visible: boolean;
  text?: string; // 可选自定义加载文本
}

/**
 * 图表数据系列接口定义
 */
export interface Series {
  type?: string;
  name?: string;
  data?: any[];
  // 其他系列属性
  [key: string]: any;
}